function baiduditu(lat,lon){
    var systemType = api.systemType;
    var buttons = new Array();
    var amap_installed = false;
    var bmap_installed = false;
    if(systemType=='ios'){
        var installed = api.appInstalled({
            sync: true,
            appBundle:'iosamap://'
        });
        if (installed) {
            amap_installed = true;
            buttons.push('高德地图');
        }
        var installed = api.appInstalled({
            sync: true,
            appBundle:'baidumap://'
        });
        if (installed) {
            bmap_installed = true;
            buttons.push('百度地图');
        }
    }else{
        var installed = api.appInstalled({
            sync: true,
            appBundle: 'com.autonavi.minimap'
        });
        if (installed) {
            amap_installed = true;
            buttons.push('高德地图');
        }
        var installed = api.appInstalled({
            sync: true,
            appBundle: 'com.baidu.BaiduMap'
        });
        if (installed) {
            bmap_installed = true;
            buttons.push('百度地图');
        }
    }
    if(bmap_installed==false && amap_installed==false){
        api.toast({
            msg:'您没有安装任何地图软件'
        });
        return false;
    }
    // 116.508616,39.960742
    var address = "终点";
    var latbaidu = lat;
    var lngbaidu = lon;
    var gaLatLng = bd_decrypt(lon, lat)
    var latgaode = gaLatLng.lat;
    var lnggaode = gaLatLng.lng;
    api.actionSheet({
        cancelTitle: '取消',
        buttons: buttons
    }, function(ret, err) {
        var index = ret.buttonIndex;

        switch (index) {
            case 1:
                if(amap_installed && bmap_installed){
                    if(systemType=='ios'){
                        api.openApp({
                            iosUrl: 'iosamap://path?sourceApplication=applicationName&sid=BGVIS1&did=BGVIS2&dlat='+latgaode+'&dlon='+lnggaode+'&dname='+address+'&dev=0&t=3',
                        }, function(ret, err) {

                        });
                    }else{
                        api.openApp({
                            androidPkg: 'android.intent.action.VIEW',
                            uri: 'amapuri://route/plan/?dlat='+latgaode+'&dlon='+lnggaode+'&dname='+address+'&dev=0&t=3'
                        }, function(ret, err) {

                        });
                    }
                }else{
                    if(amap_installed){
                        if(systemType=='ios'){
                            api.openApp({
                                iosUrl: 'iosamap://path?sourceApplication=applicationName&sid=BGVIS1&did=BGVIS2&dlat='+latgaode+'&dlon='+lnggaode+'&dname='+address+'&dev=0&t=3',
                            }, function(ret, err) {

                            });
                        }else{
                            api.openApp({
                                androidPkg: 'android.intent.action.VIEW',
                                uri: 'amapuri://route/plan/?dlat='+latgaode+'&dlon='+lnggaode+'&dname='+address+'&dev=0&t=3'
                            }, function(ret, err) {

                            });
                        }

                    }
                    if(bmap_installed){
                        if(systemType=='ios'){
                            api.openApp({
                                iosUrl: 'baidumap://map/direction?destination=latlng:'+latbaidu+','+lngbaidu+'|name:'+address+'&mode=driving&src=andr.cheyw',
                            }, function(ret, err) {
                                if (err) {

                                    //alert(JSON.stringify(err));
                                }
                            });
                        }else{
                            api.openApp({
                                androidPkg: 'android.intent.action.VIEW',
                                uri: 'baidumap://map/direction?destination=latlng:'+latbaidu+','+lngbaidu+'|name:'+address+'&mode=driving'
                            }, function(ret, err) {

                            });
                        }
                    }
                    break;
                }

            case 2:
                if(systemType=='ios'){
                    api.openApp({
                        iosUrl: 'baidumap://map/direction?destination=latlng:'+latbaidu+','+lngbaidu+'|name:'+address+'&mode=riding',
                    }, function(ret, err) {
                        if (err) {
                            //alert(JSON.stringify(err));

                        }
                    });
                }else{
                    api.openApp({
                        androidPkg: 'android.intent.action.VIEW',
                        uri: 'baidumap://map/direction?destination=latlng:'+latbaidu+','+lngbaidu+'|name:'+address+'&mode=riding'
                    }, function(ret, err) {
                        if (err) {
                            //alert(JSON.stringify(err));
                        }
                    });
                }
                break;
        }
    });
}
function bd_decrypt(bd_lng, bd_lat) {
    var X_PI = Math.PI * 3000.0 / 180.0;
    var x = bd_lng - 0.0065;
    var y = bd_lat - 0.006;
    var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * X_PI);
    var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * X_PI);
    var gg_lng = z * Math.cos(theta);
    var gg_lat = z * Math.sin(theta);
    return {lng: gg_lng, lat: gg_lat}
}